package com.example.TheParent;

import android.content.Intent;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;

import com.example.wonderfulradish.MainActivity;
import com.example.wonderfulradish.PagerViewAdapter;
import com.example.wonderfulradish.R;

import java.util.ArrayList;
import java.util.List;

public class GameRule extends AppCompatActivity {

    private View gamerule1,gamerule2;
    private ViewPager viewPager;
    private ArrayList<View> pageview;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_game_rule);

        Button return_main=(Button) findViewById(R.id.return_main);
        return_main.setOnClickListener(new View.OnClickListener() {
            public void onClick(View v) {
                Intent intent=new Intent(GameRule.this,ParentManager.class);
                startActivity(intent);
            }
        });
        viewPager=(ViewPager) findViewById(R.id.ruleView);

        LayoutInflater inflater=getLayoutInflater();
        gamerule1 =inflater.inflate(R.layout.test1pageview,null);
        gamerule2=inflater.inflate(R.layout.test2pageview,null);

        pageview=new ArrayList<View>();
        //添加想要切换的界面
        pageview.add(gamerule1);
        pageview.add(gamerule2);
        //数据适配器
        PagerViewAdapter mPagerAdapter=new PagerViewAdapter(pageview);
        //绑定适配器
        viewPager.setAdapter(mPagerAdapter);


    }
}
